<template>
  <div v-for="(item, index) in dataArr" :key="item.id" class="tw-select-none">
    <course-curriculum-menu :childrenItem="item" :courseRightBtn="courseRightBtn" :isQuestion="isQuestion"
             :type="type"               :isCourseTable="isCourseTable" @goQuestion="goQuestion"
                 :getData="getData"           @goStudyVideo="goStudyVideo"></course-curriculum-menu>
  </div>
</template>

<script setup>
import {watch} from "vue";

import CourseCurriculumMenu from "@/views/component/course-curriculum-menu.vue";

let props = defineProps({
  dataArr: {//所有参数
    type: Array,
    default: [],
  },
  courseRightBtn: {//右侧按钮是否显示 不显示：false 显示： true
    type: Boolean,
    default: true
  },
  type: {//右侧按钮是否显示 不显示：false 显示： true
    type: Number,
    default: 0
  },
  isQuestion: {//是否是题集
    type: Boolean,
    default: false
  },
  isCourseTable: {
    type: Boolean,
    default: false
  },
  getData: {
    type: Object,
  }
});
watch(() => props.dataArr, (val) => {

  traverseAndModify(val)
  // props.dataArr = val
})
const traverseAndModify = (arr) => {
  arr.forEach(item => {
    if (item.categoryFlag === 1) {
      item.isShow = false;
      item.mask = false;
    }
    if (item.children && item.children.length > 0) {
      traverseAndModify(item.children);
    }
  });
}
let emit = defineEmits(['goStudyVideo', 'goQuestion'])
const goStudyVideo = (item) => {
  emit('goStudyVideo', item)
}
const goQuestion = (item) => {
  emit('goQuestion', item)
}
</script>

<style lang="scss" scoped></style>
